package org.example.crypto.config;

import lombok.RequiredArgsConstructor;
import org.example.crypto.core.ApiDecryptParamResolver;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @program: rabbitmq-study
 * @description: 签名自动配置
 * @Version V1.0.0
 * @author: dazhi
 * @create: 2021-02-08 17:04
 **/

@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties(ApiCryptoProperties.class)
@ConditionalOnProperty(value = ApiCryptoProperties.PREFIX+".enabled",havingValue = "true", matchIfMissing = true)
public class ApiCryptoConfiguration implements WebMvcConfigurer {

    private final  ApiCryptoProperties apiCryptoProperties;
    //实现自定义参数解析器
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolverList){
        argumentResolverList.add(new ApiDecryptParamResolver(apiCryptoProperties));
    }
}
